//csvcontenttitle
export class Csv {
    public static csvData: { [key: string]: any[] } = {};

    public static loadAllCsv(): void {
        //csvloadall
    }
    public static parseCsv(csvName: string, data: string): void {
        const lines: string[] = data.split("\n");

        const valueTypes: string[] = lines[1].split("&");
        this.csvData[csvName] = [];
        for (let line = 1; line < lines.length; line++) {
            const lineValues: string[] = lines[line].split("&");

            for (let index = 0; index < lineValues.length; index++) {
                let value: any = lineValues[index];
                const valueType: string = valueTypes[index];
                if (valueType === "number") {
                    value = String(value);
                }
                else if (valueType === "string") {
                    value = String(value);
                }
                else if (valueType === "sarray") {
                    value = value.split(",");
                }
                else if (valueType === "iarray") {
                    const params: number[] = [];
                    for (const v of value.split(",")) {
                        params.push(Number(v));
                    }
                    value = params;
                }
                this.csvData[csvName].push(value);
            }
        }
    }
}


